package com.noyes4j.customer.service.impl;

import com.noyes4j.common.core.text.Convert;
import com.noyes4j.common.utils.DateUtils;
import com.noyes4j.customer.domain.SysCustomer;
import com.noyes4j.customer.mapper.SysCustomerMapper;
import com.noyes4j.customer.service.ISysCustomerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName SysCustomerServiceImpl
 * @Description: TODO
 * @Author zhaoweiqin
 * @Date 2021/1/29
 * @Version V1.0
 **/
@Service
public class SysCustomerServiceImpl implements ISysCustomerService {


    @Autowired
    private SysCustomerMapper sysCustomerMapper;

    /**
     * 查询客户
     *
     * @param id 客户ID
     * @return 客户
     */
    @Override
    public SysCustomer selectSysCustomerById(Long id)
    {
        return sysCustomerMapper.selectSysCustomerById(id);
    }

    /**
     * 查询客户列表
     *
     * @param sysCustomer 客户
     * @return 客户
     */
    @Override
    public List<SysCustomer> selectSysCustomerList(SysCustomer sysCustomer)
    {
        return sysCustomerMapper.selectSysCustomerList(sysCustomer);
    }

    /**
     * 新增客户
     *
     * @param sysCustomer 客户
     * @return 结果
     */
    @Override
    public int insertSysCustomer(SysCustomer sysCustomer)
    {
        sysCustomer.setCreateTime(DateUtils.getNowDate());
        return sysCustomerMapper.insertSysCustomer(sysCustomer);
    }

    /**
     * 修改客户
     *
     * @param sysCustomer 客户
     * @return 结果
     */
    @Override
    public int updateSysCustomer(SysCustomer sysCustomer)
    {
        sysCustomer.setUpdateTime(DateUtils.getNowDate());
        return sysCustomerMapper.updateSysCustomer(sysCustomer);
    }

    /**
     * 删除客户对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteSysCustomerByIds(String ids)
    {
        return sysCustomerMapper.deleteSysCustomerByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除客户信息
     *
     * @param id 客户ID
     * @return 结果
     */
    @Override
    public int deleteSysCustomerById(Long id)
    {
        return sysCustomerMapper.deleteSysCustomerById(id);
    }
}
